<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/layui/2.6.8/css/layui.min.css">
    <link type="text/css" href="${pageContext.request.contextPath}/shop/admin/css/Admin.css" rel="stylesheet"/>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <%@ include file="../header-side.jsp"%>
    <script>
        if((window.location.pathname).indexOf('notice')>=0 || (window.location.pathname).indexOf('Notice')>=0){
            document.getElementsByClassName('notice')[0].className+='  layui-this '
        }
    </script>
    <div class="layui-body" >
        <!-- 内容主体区域 -->
        <div class="tables" style="width: 895px;">
            <span class="layui-breadcrumb">
              <a href="${pageContext.request.contextPath}/shop/client">首页</a>
              <a><cite>公告管理</cite></a>
            </span>
            <hr>
            <a href="notice/modify.jsp">
                <button class=" btnadd layui-btn layui-btn-normal">增加</button>
            </a>
            <table class="layui-table" lay-even lay-skin="row">
                <tr>
                    <th>ID</th>
                    <th>公告标题</th>
                    <th>发布日期</th>
                    <th>管理</th>
                </tr>
                <c:forEach var="item" items="${noticeList}">
                    <tr>
                        <td>${item.n_id}</td>
                        <td>${item.title}</td>
                        <td>${item.n_time}</td>
                        <td>
                            <!-- 查看 -->
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary"
                                    onclick="window.location.href='modifyNotice?id=${item.n_id}'">
                                <i class="layui-icon layui-icon-list"></i>
                            </button>
                            <!-- 修改 -->
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary"
                                    onclick="window.location.href='modifyNotice?id=${item.n_id}'">
                                <i class="layui-icon layui-icon-edit"></i>
                            </button>
                            <!-- 删除 -->
                            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary"
                                    onclick="delNotice(${item.n_id})">
                                <i class="layui-icon layui-icon-delete"></i>
                            </button>
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/layui/2.6.8/layui.min.js"></script>
<script>
    function delNotice(id){
        layer.confirm('确认删除该公告吗？', {
            btn: ['确认', '取消'], //可以无限个按钮
            btn1: function(index, layero){
                window.location.href = 'removeNotice?id='+id
                return true;
            }
        });
    }
    //JS
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element
            , layer = layui.layer
            , util = layui.util
            , $ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            //左侧菜单事件
            menuLeft: function (othis) {
                layer.msg('展开左侧菜单的操作', {icon: 0});
            }
            , menuRight: function () {
                layer.open({
                    type: 1
                    , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
                    , area: ['260px', '100%']
                    , offset: 'rt' //右上角
                    , anim: 5
                    , shadeClose: true
                });
            }
        });

    });
</script></body>
</html>
